package com.qfedu.job.listeners;

import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.TriggerListener;

/**
 * 触发器监听器
 */
public class MyTriggerListener implements TriggerListener {
    @Override
    public String getName() {
        return "MyTriggerListener1";
    }

    @Override
    public void triggerFired(Trigger trigger, JobExecutionContext context) {
        // 触发器被触发，执行任务之前执行
        System.out.println("~~~~~~~~~triggerFired");
    }

    @Override
    public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) {
        return false; // 表示任务执行失败
    }

    @Override
    public void triggerMisfired(Trigger trigger) {
        // 错失触发
        System.out.println("~~~~~~~~~triggerMisfired");
    }

    @Override
    public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode) {
        // 触发器触发完成
        System.out.println("~~~~~~~~~triggerComplete");
    }
}
